package popup;

import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

/**
 *
 * @author Sawior
 */
public class ScanPopupController {

    @FXML
    private TextField textPopup;
    private Stage dialogStage;
    private int count = 1;
    private String incomming = "";
    
    public void setDialogStage(Stage dialogStage) {
        this.dialogStage = dialogStage;
        scanActionGetter();
    }

    private void scanActionGetter() {
        textPopup.textProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observable,
                    String oldValue, String newValue) {

                if(count == 13){
                    incomming = newValue;
                    dialogStage.close();
                }
                else {
                    count++;
                }
            }
        });
    }

    public String getIncomming() {
        return incomming;
    }
    
}
